import { game } from "cc";
import BTAction from "../../Base/BTAction";
import Blackboard from "../../Blackboard";
import { NodeStatus } from "../../Enum";

export default class ActionWork extends BTAction
{
    private duration: number = 2000;
    private startTime: number = 0;
    constructor(duration: number = 2000)
    {
        super();
        this.duration = duration;
    }

    onStart()
    {
        super.onStart();
        this.startTime = game.totalTime;
        console.log("Work start");
    }

    onUpdate()
    {
        if (game.totalTime - this.startTime > this.duration)
        {
            return NodeStatus.Success;
        }
        return NodeStatus.Running;
    }

    onEnd()
    {
        super.onEnd();
        console.log("Work end");
    }
}